﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Core.ObjectOperate
{
    public interface IObjectOperater
    {
        /// <summary>
        /// 获得这个类型操作器所操作的类型
        /// </summary>
        Type Type { get; }

        /// <summary>
        /// 调用函数
        /// </summary>
        /// <param name="Object">需要调用函数的实例</param>
        /// <param name="MethodName">函数名称</param>
        /// <param name="Params">函数的参数</param>
        /// <returns>返回函数的返回值</returns>
        object InvokeMethod(object Object, string MethodName,  object[] Params);

        /// <summary>
        /// 调用函数
        /// </summary>
        /// <param name="Object">需要调用函数的实例</param>
        /// <param name="MethodIndex">函数的索引</param>
        /// <param name="Params">函数的参数</param>
        /// <returns>返回函数的返回值</returns>
        object InvokeMethod(object Object, int MethodIndex, object[] Params);

        /// <summary>
        /// 获得函数的索引
        /// </summary>
        /// <param name="MethodName">需要获取索引的函数名称</param>
        /// <param name="MethodTypes">函数的参数类型</param>
        /// <returns>返回这个函数的索引，没有找到则返回 -1。</returns>
        int GetMethodIndex(string MethodName, Type[] MethodTypes);

        /// <summary>
        /// 获得函数的名称
        /// </summary>
        /// <param name="MethodIndex">需要获取名称的函数索引</param>
        /// <returns>返回这个函数的名称。</returns>
        string GetMethodName(int MethodIndex);

        /// <summary>
        /// 获得函数的参数类型
        /// </summary>
        /// <param name="MethodIndex">需要获取参数类型的函数索引</param>
        /// <returns>返回这个函数的参数类型。</returns>
        Type[] GetMethodTypes(int MethodIndex);

        /// <summary>
        /// 获得函数的返回值类型
        /// </summary>
        /// <param name="MethodIndex">需要获取返回值类型的函数索引</param>
        /// <returns>返回这个函数的返回值类型</returns>
        Type GetMethodType(int MethodIndex);

        /// <summary>
        /// 获得函数的返回值类型
        /// </summary>
        /// <param name="MethodName">需要获取返回值类型的函数名称</param>
        /// <param name="MethodTypes">函数的参数类型</param>
        /// <returns>返回这个函数的返回值类型</returns>
        Type GetMethodType(string MethodName, Type[] MethodTypes);

        /// <summary>
        /// 获得这个类型的函数总数
        /// </summary>
        int MethodsCount { get; }


        object GetIndexValue(object Object, object[] Params);

        void SetIndexValue(object Object, object[] Params, object Value);

        object GetIndexValue(object Object, int IndexIndex, object[] Params);

        void SetIndexValue(object Object, int IndexIndex, object[] Params, object Value);

        int GetIndexIndex(Type[] IndexTypes);

        Type[] GetIndexTypes(int IndexIndex);

        Type GetIndexType(int IndexIndex);

        Type GetIndexType(Type[] IndexTypes);

        int IndexesCount { get; }



        object GetPropertyValue(object Object, string PropertyName);

        void SetPropertyValue(object Object, string PropertyName, object Value);

        object GetPropertyValue(object Object, int PropertyIndex);

        void SetPropertyValue(object Object, int PropertyIndex, object Value);

        int GetPropertyIndex(string PropertyName);

        string GetPropertyName(int PropertyIndex);

        Type GetPropertyType(int PropertyIndex);

        Type GetPropertyType(string PropertyName);

        int PropertiesCount { get; }




        object GetFieldValue(object Object, string FieldName);

        void SetFieldValue(object Object, string FieldName, object Value);

        object GetFieldValue(object Object, int FieldIndex);

        void SetFieldValue(object Object, int FieldIndex, object Value);

        int GetFieldIndex(string FieldName);

        string GetFieldName(int FieldIndex);

        Type GetFieldType(int FieldIndex);

        Type GetFieldType(string FieldName);

        int FieldsCount { get; }



        object New(object[] Params);

        object New();

        int GetConstructorIndex(Type[] ConstructorsTypes);

        Type[] GetConstructorTypes(int ConstructorIndex);

        int ConstructorsCount { get; }
    }
}
